<template>
	<view>
		<u-loading-page :loading="loadding" loading-mode="semicircle" loading-text="Hello Pro"></u-loading-page>
		<view class="data_box" v-if="!loadding">
			<!-- 交易 -->
			<view class="data_list">
				<view class="data_tit">
					<view class="tit">
						<text>交易数据</text>
						<!-- <h3>{{data.tran.sum}}</h3> -->
					</view>
				</view>
				<view class="data_cont">
					<view class="" @click="tranDataInfo(1)">
						<text class="h4">我的交易额</text>
						<text class="total">{{data.tran.self_total}}</text>
					</view>
					<view class="" @click="tranDataInfo(2)">
						<text class="h4">团队交易额</text>
						<text class="total">{{data.tran.team_total}}</text>
					</view>
				</view>
				<view class="data_end">
					<text style="color: #999;">总交易额</text>
					<text class="total">{{data.tran.all_total}}</text>
				</view>
			</view>
			<!-- 激活 -->
			<view class="data_list">
				<view class="data_tit">
					<view class="tit">
						<text>激活数据</text>
						<!-- <h3>{{data.active.month}}</h3> -->
					</view>
				</view>
				<view class="data_cont">
					<view class="" @click="activeDataInfo(1)">
						<text class="h4">我的激活</text>
						<text class="total">{{data.active.self_total}}</text>
					</view>
					<view class="" @click="activeDataInfo(2)">
						<text class="h4">团队激活</text>
						<text class="total">{{data.active.team_total}}</text>
					</view>
				</view>
				<view class="data_end">
					<text style="color: #999;">总激活</text>
					<text class="total">{{data.active.all_total}}</text>
				</view>
			</view>
			<!-- 团队 -->
			<view class="data_list">
				<view class="data_tit" style="margin-bottom: 20rpx;">
					<view class="tit">
						<text>团队数据</text>
						<!-- <h3>{{data.child.month}}</h3> -->
					</view>
					<!-- <text class="end">团队数据</text> -->
				</view>
				<view class="data_end bottom_line" style="padding-bottom: 24rpx" @click="team(1)">
					<text style="color: #999;">我的直营</text>
					<text class="total">{{data.team.month}}</text>
				</view>
				<view class="data_end" style="padding-top: 24rpx" @click="team(2)">
					<text style="color: #999;">团队总数</text>
					<text class="total">{{data.team.total}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loadding: true,
				data: {
					tran: {},
					team: {},
					active: {},
				},
				version: '',
				versionHref: 'version1',
				// menu: []
			}
		},
		onLoad() {
			this.version = uni.getStorageSync('version')
			if (this.version == '5.0') {
				this._list5()
				// this._menu5()
				this.versionHref = 'version5'
				uni.setTabBarItem({
					index: 1,
					visible: true
				})
			} else {
				this._list()
				// this._menu()
				this.versionHref = 'version1'
				uni.setTabBarItem({
					index: 1,
					visible: false
				})
			}
		},
		onShow() {
			this.version = uni.getStorageSync('version')
			if (this.version == '5.0') {
				this._list5()
				// this._menu5()
				this.versionHref = 'version5'
				uni.setTabBarItem({
					index: 1,
					visible: true
				})
			} else {
				this._list()
				// this._menu()
				this.versionHref = 'version1'
				uni.setTabBarItem({
					index: 1,
					visible: false
				})
			}
		},
		methods: {
			//页面数据
			async _list() {
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp({
					url: 'Datas/getTotalData',
					// data: {},
					header: {
						'token': userinfo.token
					}
				});
				this.loadding = false
				this.data.tran = res.data.tran
				this.data.team = res.data.team
				this.data.bonus = res.data.bonus
				this.data.active = res.data.active
			},
			async _list5() {
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp5({
					url: 'Datas/getTotalData',
					// data: {},
					header: {
						'token': userinfo.token
					}
				});
				this.loadding = false
				this.data.tran = res.data.tran
				this.data.team = res.data.team
				this.data.bonus = res.data.bonus
				this.data.active = res.data.active
			},
			tranDataInfo(e) {
				uni.navigateTo({
					url: '/pages/' + this.versionHref + '/data/transaction/data_detailed?type=' + e
				})
			},
			activeDataInfo(e) {
				uni.navigateTo({
					url: '/pages/' + this.versionHref + '/data/active/data_detailed?type=' + e
				})
			},
			//团队
			team(type) {
				if (this.version == '1.0') {
					uni.navigateTo({
						url: '/pages/' + this.versionHref + '/data/team/team_info?type=' + type
					})
				} else if (this.version == '5.0') {
					uni.navigateTo({
						url: '/pages/' + this.versionHref + '/data/team/team5?type=' + type
					})
				}
			},
			// 菜单展示
			async _menu() {
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp({
					url: 'menu/getData',
					// data: {},
					header: {
						'token': userinfo.token
					}
				});
				if (res.code == 1) {
					this.menu = res.data
				}
			},
			async _menu5() {
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp5({
					url: 'menu/getData',
					// data: {},
					header: {
						'token': userinfo.token
					}
				});
				if (res.code == 1) {
					this.menu = res.data
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.data_box {
		padding: 30rpx;

		.data_list {
			box-sizing: border-box;
			margin-bottom: 30rpx;
			border-radius: 15rpx;
			box-shadow: 7px 0px 30px -18px #888888;
			padding-bottom: 20rpx;

			.data_tit {
				padding: 30rpx;
				padding-right: 0;
				border-bottom: #eee 1px solid;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.tit {
					text {
						font-size: 32rpx;
						position: relative;
						padding-left: 30rpx;
						line-height: 32rpx;
						font-weight: bold;
					}

					text::before {
						position: absolute;
						content: '';
						height: 90%;
						margin-top: 2%;
						width: 10rpx;
						background-color: #2f9fff;
						border-radius: 30rpx;
						left: 0;
					}

					h3 {
						margin-top: 20rpx;
						font-weight: 500;
						font-size: 42rpx;
						color: #333;
					}
				}

				.end {
					font-size: 28rpx;
					background-image: linear-gradient(#2f9fff, #5999ff);
					padding: 10rpx 30rpx;
					border-top-left-radius: 30rpx;
					border-bottom-left-radius: 10rpx;
					color: #fff;
				}
			}

			.data_cont {
				display: flex;
				flex-direction: column;
				padding: 30rpx;
				justify-content: space-around;
				padding-top: 0;
				border-bottom: #eee 1px solid;
				margin-bottom: 20rpx;
				text-align: end;

				text {
					font-size: 32rpx;
					color: #2f9fff;
					display: block;
					margin-top: 20rpx;

				}

				.h4 {
					font-size: 28rpx;
					width: fit-content;
					color: #999;
					text-align: left;
					border-bottom: #eee solid 0px;

				}

				view:last-child {
					border: none;
					padding-bottom: 0;
				}

				.items {
					margin-top: 20rpx;
					border-radius: 15rpx;
					box-shadow: 7px 0px 30px -18px #888888;

					.titles {
						margin: 0 20rpx;
						padding: 20rpx 0;
						border-bottom: 1px dashed #f4f4f5;
						display: flex;
						justify-content: space-between;
						font-weight: bold;
					}

					.share-total {
						padding: 20rpx;
						display: flex;
						justify-content: space-between;

						text {
							margin-top: 0rpx;
							font-size: 28rpx;
							color: #333;
						}

						.moneys {
							width: 50%;
							display: flex;
							justify-content: center;

							.m-total {
								font-weight: bold;
							}
						}

						.standard {
							width: 50%;
							display: flex;
							justify-content: center;

							.numbers {
								padding: 0 10rpx;
								font-weight: bold;
								color: #fa3534;
							}

							.detail {
								font-size: 24rpx;
								padding-left: 10rpx;
								padding-top: 2rpx;
								color: #2f9fff;
							}
						}
					}
				}
			}

			.data_end {
				display: flex;
				padding: 10rpx 30rpx;
				color: #ff7307;
				font-size: 28rpx;
				align-items: center;
				justify-content: space-between;
				line-height: 40rpx;

				.total {
					font-weight: bold;
					font-size: 32rpx;

				}
			}
		}
	}

	.bottom_line {
		border-bottom: 1px dashed #eee;
	}

	.no-p-t {
		padding-bottom: 0rpx !important;
	}

	.no-b-b {
		border-bottom: none !important;
	}
</style>